$def with (page)

<div class="head">
    <h2>
    $commify(page.edition_count) editions
    $if page.first_publish_year:
        <span class="count">$_("First published in %(year)s", year=page.first_publish_year)</span>
    -
    <span class="count">
        <a href="/books/add?work=$page.key" title="$_('Add another edition of %(work)s', work=page.title)">$_("Add another")</a>
    </span>

    | <span class="count fixthis"><a href="#">$_("Merge duplicates")</a></span>
    </h2>
</div>

$def render_edition():
    <td class="book">
        <span class="hidden count"></span>
        <div class="cover">
            <a href="$book.url()"><img src="$url" alt="$_('Cover of: %(title)s', title=book.title)" title="$_('Cover of: %(title)s', title=book.title)"/></a>
        </div>
        <div class="title">
            <div class="published">
            $if book.publishers and book.publish_date:
                $book.publish_date, $(', '.join(book.publishers))
            $elif book.publish_date:
                $book.publish_date
            $elif book.publishers:
                <em>$_('Publish date unknown')</em>, $(', '.join(book.publishers))
            $else:
                <em>$_('Publisher unknown')</em>
            </div>
            $if book.title:
                <a href="$book.url()">$book.title</a><br/>
            $else:
                <a href="$book.url()"><em>$_('Title missing')</em></a><br/>
            <div class="format">
                $book.physical_format.replace('[', '').replace(']','')
                $if book.languages:
                  $:_('in %(languagelist)s', languagelist=commify_list(thingrepr(l) for l in book.languages))
            $if book.edition_name:
                -
                $book.edition_name
            </div>
        </div>
    </td>

<table id="listResults" class="list-books">
$for e in page.get_sorted_editions():
    <tr>$:render_edition(e)</tr>
</table>
